package wang.conge.javasedemo.core.thread;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchTest {

	public static void main(String[] args) {
		CountDownLatch countDownLatch = new CountDownLatch(3);
		
		for (int i = 0; i < 3; i++) {
			new Thread(()->{
				System.out.println("child thread run");
				countDownLatch.countDown();
			}).start();
		}
		
		System.out.println("main thread run");
		
		try {
			countDownLatch.await();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		System.out.println("main thread finished");
	}

}
